using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using DataTransferObject;
using Business;


namespace Presentation.UserControlls
{
    public partial class UC_MuonTrongThang : UserControl
    {
        clsCTMuonTraDTO ctmuontraDTO = new clsCTMuonTraDTO();
        clsCTMuonTraBUS ctmuontraBUS = new clsCTMuonTraBUS();
        clsThuThuBUS ThuThuBUS = new clsThuThuBUS();

        DataTable tbl = new DataTable();
        int tongcong = 0;

        public UC_MuonTrongThang()
        {
            InitializeComponent();
        }

        private void UC_MuonTrongThang_Load(object sender, EventArgs e)
        {
            
            
           
        }

        private void HienThiListView(DataTable tbl)
        {
            tongcong = 0;
            ListViewItem lvwitem = new ListViewItem();
            lvwthongkesachdamuon.Items.Clear();
            foreach (DataRow dr in tbl.Rows)
            {



                tongcong = tongcong + 1;
                lvwitem = new ListViewItem();
                lvwitem.Text =Convert .ToString ( tongcong.ToString ());
                lvwitem.SubItems.Add(dr["TenTL"].ToString());
                lvwitem.SubItems.Add(dr["SoLuotMuon"].ToString());
                lvwthongkesachdamuon.Items.Add(lvwitem);

            }

        }

        private void cbb_Thang_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbb_Thang.Text != "")
            {

                int thang = Convert.ToInt32(cbb_Thang.Text);

                tbl = ThuThuBUS.CTMuonTraBUS.ThongKeSachMuonTheoTheLoai(thang);
                HienThiListView(tbl);
            }

        }

        private void buttonX3_Click(object sender, EventArgs e)
        {
            FromInAn.FrmMuonSachTheTheLoai muonthetheloai = new Presentation.FromInAn.FrmMuonSachTheTheLoai();
           
            //muonthetheloai.thang = Convert.ToInt32(cbb_Thang.Text);
            if (cbb_Thang .Text  == "")
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("Không Thể In Phiếu Được", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                return;
            }
            else
            {
                muonthetheloai.thang = Convert.ToInt32(cbb_Thang.Text);
                muonthetheloai.Show();
            }
           

            
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            DialogResult dlg = new DialogResult();
            dlg = DevComponents.DotNetBar.MessageBoxEx.Show("Bạn có muốn thoát không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dlg == DialogResult.Yes)
            {
                this.ParentForm.Close();

            }
        }
    }
}
